with Currency;
with ada.text_io;
with ada.float_text_io;
with ada.integer_text_io;

package employees is
    type PayCategories is (Unknown, Professional, Sales, Clerical) ;

    package PayCategories_IO is new ada.text_io.enumeration_io (PayCategories);
    package pc_io renames PayCategories_io;
    package t_io renames ada.text_io;
    package f_io renames ada.float_text_io;
    package i_io renames ada.integer_text_io;

    type Employee ( PayStatus : PayCategories := Unknown) is record
      ID : Positive ;
      NameLength : Positive ;
      Name : String (1..20) ;
      case PayStatus is
	when Professional => MonthlySalary : Float ;
	when Sales =>
	  WeeksSalary : Float ;
	  CommRate : Float ;
	  SalesAmount : Float ;
	when Clerical =>
	  HourlyWage : Currency.Quantity ;
	when Unknown =>
	  null ;
      end case ;
    end record ;

    procedure get (file : in t_io.File_Type; emp : out Employee) is
	cat	       : PayCategories;
	ID, 
	NameLength     : Positive;
	Name	       : String (1..20);
	Salary, 
	CommRate, 
	SalesAmount    : Float;
	HourlyWage     : Currency.Quantity;
    begin
	pc_io.get (file, cat);
	i_io.get (file, ID);
	i_io.get (file, NameLength);
	t_io.get (file, Name (1..NameLength));
	case cat is
	    when Professional =>
		f_io.get(file, salary);
		emp := Employee' (PayStatus     => cat,
				  ID	        => ID,
				  NameLength    => NameLength,
				  Name	        => Name,
				  MonthlySalary => Salary);
	    when Sales =>
		f_io.get (file, Salary);
		f_io.get (file, CommRate);
		f_io.get (file, SalesAmount);
		emp := Employee' (PayStatus     => cat,
				  ID	        => ID,
				  NameLength    => NameLength,
				  Name	        => Name,
				  WeekSalary    => Salary,
				  CommRate	=> CommRate,
				  SalesAmount   => SalesAmount);
	    when Clerical =>
		--GET CURRENCY
		emp := Employee' (PayStatus     => cat,
				  ID	        => ID,
				  NameLength    => NameLength,
				  Name	        => Name,
				  HourlyWage    => HourlyWage);
	    when Unknown =>
		emp := Employee' (PayStatus     => cat,
				  ID	        => ID,
				  NameLength    => NameLength,
				  Name	        => Name);
	end case;
    end get;

    procedure put (emp : in Employee) is
    begin
	pc_io.put_line (emp.PayStatus);
	i_io.put (emp.ID, 0);
	t_io.new_line;
	i_io.put (emp.NameLength, 0);
	t_io.new_line;
	t_io.put_line (emp.Name (1..emp.NameLength));
	case emp.PayStatus is
	    when Professional =>
		f_io.put (emp.MonthlySalary, 0, 2, 0);
	    when Sales =>
		f_io.put (emp.WeeklySalary, 0, 2, 0);
		t_io.new_line;
		f_io.put (emp.CommRate, 0, 2, 0);
		t_io.new_line;
		f_io.put (emp.SalesAmount, 0, 2, 0);
	    when Clerical =>
		--OUTPUT HourlyWage
	    when Unknown => NULL;
	end case;
	t_io.new_line (2);
    end put;
	
end employees;

